<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>Blog</title>
	<script type="text/javascript" src="<?php echo  base_url() ?>public/js/jQuery.min.js"></script>
	<script type="text/javascript" src="<?php echo  base_url() ?>public/js/bootstrap.min.js"></script>
	<link href="<?php echo  base_url() ?>public/css/bootstrap.min.css" rel="stylesheet">
    <link href="<?php echo  base_url() ?>public/css/bootstrap-theme.min.css" rel="stylesheet">
    <link href="<?php echo  base_url() ?>public/css/basic.css" rel="stylesheet">
    <link href="<?php echo  base_url() ?>public/css/style.css" rel="stylesheet">
</head>
<body>
<?php $this->load->view('admin/header')	?>
<table class="table wd960 ml0 mt50">
			<tr>
				<td>标题</td>
				<td>创建时间</td>
				<td>访问人数</td>
				<td>操作<a href="<?php echo site_url('admin/article/add_one'); ?>"><button type="button" class="btn btn-info">添加</button></a></td>
			</tr>
		<?php foreach ($articles as $data)
			{
		?>
			<tr>
				<td><a href="#"><?php echo $data['title'] ?></a></td>
				<td><?php echo date("Y年m月d日 H:i:s",$data['create_time']) ?></td>
				<td><?php echo $data['view'] ?></td>
				<td>
		<?php if ( $data['recommend']==0) {
		
		?>
				<a class="btn btn-success btn-sm recommend" href="<?php echo site_url('admin/article/rec_one/'. $data['id']); ?>">推荐</a>
		<?php } else{ ?>
				<a class="btn btn-primary btn-sm recommend" href="<?php echo site_url('admin/article/rec_one/'. $data['id']); ?>">取消推荐</a>
		<?php } ?>
				<a class="btn btn-warning btn-sm edit" href="<?php echo site_url('admin/article/edit_one/'. $data['id']); ?>">编辑</a>
				<a class="btn btn-danger btn-sm del" href="<?php echo site_url('admin/article/del_one/'. $data['id']); ?>">删除</a>
				</td>
			</tr>
		<?php
			}
		?>		
	</table>
	<div class="wd960 ml0 tc"><?php echo $this->pagination->create_links();?></div>

	<div id="myBody" class="modal fade  modal-lg">
	  <div class="modal-dialog">
	    <div class="modal-content">
	      <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
	        <h4 class="modal-title">Modal title</h4>
	      </div>
	      <div id="divAlt" class="modal-body modal-lg">
	      </div>
	      <div class="modal-footer">
	        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
	        <button type="button" class="btn btn-primary">Save changes</button>
	      </div>
	    </div><!-- /.modal-content -->
	  </div><!-- /.modal-dialog -->
	</div><!-- /.modal -->
</body>
	<script type="text/javascript">
		$(function(){//建立函数
			$(".recommend").click(function(){//选中并绑定事件
				var href=$(this).attr('href');   //给href赋值调用代码中的href
				$.get(href,function(){//直接用这么函数，把赋值过的herf给这个函数，
					location.reload();//当前页面刷新。
				});
				return false;
			});
			$(".del").click(function(){//选中并绑定事件
				var href=$(this).attr('href');   //给href赋值调用代码中的href
				if (!confirm('是否删除？')) {
					return false;
				}else{
				$.get(href,function(){//直接用这么函数，把赋值过的herf给这个函数，
					location.reload();//当前页面刷新。
				});
				return false;
				}
			});
			$(".edit").click(function(){//选中并绑定事件
				$('#myBody').modal('show');
				var href=$(this).attr('href'); 
				$.get(href,function(data){//直接用这么函数，把赋值过的herf给这个函数，
					$('#myBody .modal-body').html(data);
				});
				return false;
			});
		});


	</script>
</html>
